<style>

</style>
<div class="layuimini-container layuimini-page-anim">
    <div class="layuimini-main">

        <form class="layui-form layui-form-pane" action="" lay-filter="eduStudentInfo">

            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                <legend>基本信息</legend>
            </fieldset>


            <div class="layui-row layui-col-space20">
                <div class="layui-col-xs12 layui-col-md8">
                    <!--教师工号-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">学生学号：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="id" lay-verify="title" autocomplete="off" class="layui-input" disabled>
                        </div>
                    </div>
                    <!--姓名-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">姓名：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="name" lay-verify="title" autocomplete="off" placeholder="刘备" class="layui-input" disabled>
                        </div>
                    </div>
                    <!--性别-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">性别：</label>
                        <div class="layui-input-block">
                            <input type="radio" name="gender" value="0" title="男" checked="" disabled>
                            <input type="radio" name="gender" value="1" title="女" disabled>
                        </div>
                    </div>
                    <!--院系-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">所属学院：</label>
                        <div class="layui-input-inline">
                            <select name="academy" lay-filter="academy" disabled>
                                <option value="201">文学院</option>
                                <option value="202">金融学院</option>
                                <option value="203">信息学院</option>
                                <option value="204">外语学院</option>
                            </select>
                        </div>
                    </div>
                </div>
                <!--证件照预览-->
                <div class="layui-col-xs12 layui-col-md4" align="center">
                    <img src="" alt=""
                         width="130px" height="180px" class="layui-box" id="photo">
                </div>
            </div>

            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                <legend>更多信息</legend>
            </fieldset>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">日期选择</label>
                    <div class="layui-input-block">
                        <input type="text" name="birth" id="birth" autocomplete="off" class="layui-input" disabled>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">验证手机</label>
                    <div class="layui-input-inline">
                        <input type="tel" name="phone" lay-verify="phone" autocomplete="off" class="layui-input" disabled>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">邮箱</label>
                    <div class="layui-input-inline">
                        <input type="email" name="email" lay-verify="email" autocomplete="off" class="layui-input" disabled>
                    </div>
                </div>
            </div>

        </form>

    </div>
</div>
<script th:inline="text">
    layui.use(['jquery', 'form','layedit', 'laydate','layer'], function () {

        var $ = layui.jquery
            ,form = layui.form
            ,layedit = layui.layedit
            ,laydate = layui.laydate;

        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.render();

        //日期
        laydate.render({
            elem: '#birth',
        });

        //获取当前登录用户
        var eduTeacher = JSON.parse(sessionStorage.getItem("eduTeacher"));

        console.log(eduTeacher);

        var studentId = [[${studentId}]];

        $.ajax({
            url: "http://localhost/api/teacher/student/"+studentId,
            headers:{
                "token": eduTeacher.token,
            },
            type:"get",
            success: function (result) {
                var eduStudent = result.data;
                //初始化学生信息
                form.val('eduStudentInfo',{
                    "id" : eduStudent.id,
                    "name": eduStudent.name,
                    "password": eduStudent.password,
                    "gender": eduStudent.gender,
                    "academy": eduStudent.academy,
                    "birth": eduStudent.birth,
                    "email": eduStudent.email,
                    "phone": eduStudent.phone
                });

                if (eduStudent.photo != null && eduStudent.photo != ""){
                    $("#photo").attr("src",eduStudent.photo);
                }


            },
            error: function (result) {
                console.log(result)
            }
        })


    })
</script>